using System.Linq;
using Blackbird.Core.Editable.Frames;
using Blackbird.Core.Entities.Sprites;
using Microsoft.Xna.Framework.Content.Pipeline;

namespace Blackbird.Pipeline
{
    /// <summary>
    /// This class will be instantiated by the XNA Framework Content Pipeline
    /// to apply custom processing to content data, converting an object of
    /// type TInput to TOutput. The input and output types may be the same if
    /// the processor wishes to alter data without changing its type.
    ///
    /// This should be part of a Content Pipeline Extension Library project.
    ///
    /// </summary>
    [ContentProcessor(DisplayName = "Blackbird.Pipeline.FramesetListProcessor")]    
    public class FramesetListProcessor : ContentProcessor<EditableFramesetList, FramesetList>
    {
        public override FramesetList Process(EditableFramesetList input, ContentProcessorContext context)
        {
            var framesetList = new FramesetList
                                   {
                                       Name = input.Name,
                                       Capacity = input.Count
                                   };

            var processor = new FramesetProcessor();
            framesetList.AddRange(input.Select(editableFrameset => processor.Process(editableFrameset, context)));

            return framesetList;
        }
    }
}